Fix/cs builder context leak#4903
Closed
JohnLangford wants to merge 5 commits intomasterfrom
Closed
Conversation
CreateBuilder() allocates a builder_context on the heap but DeleteBuilder() never called delete on it, leaking ~40 bytes per namespace per example. Closes #4900
The features_have_names/hashes/values helpers called ->size() after IsFieldPresent() without checking for nullptr. On Windows debug builds, intentionally malformed flatbuffers (from BadNamespace_* tests) could have a present-but-null field, causing SEH access violations (0xc0000005).
start_ns_extent() was called before validation but end_ns_extent() was only called on the success path. When RETURN_NS_PARSER_ERROR fired, the extent was left open (end_index == 0), causing crashes on Windows debug builds (SEH 0xc0000005) when the example was later cleaned up. Uses a scope_exit guard to ensure end_ns_extent is always called.
- DeleteWorkspace() allocated workspace_context with new but never freed it, leaking memory on every workspace creation/deletion cycle. - IOWriterAdapter in SaveModel(Stream) and IOReaderAdapter in CreateWorkspaceWithModelData could be garbage collected during the native call since no managed references remained after GetVTable(). Added GC.KeepAlive() to prevent premature collection. Addresses remaining memory leaks reported in #4900.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.